var status = -1;
var selectionLog = [];
var 通用强化材料 = 4001878;

function start() {
    action(1, 0, 0)
}

function action(d, b, a) {
    if (status == 0 && d == 0) {
        cm.dispose();
        return
    }
    if (d == 1) {
        status++
    } else {
        status--
    }
    selectionLog[status] = a;
    if (status == 0) {
        cm.askMenu("#e[起源之塔排名公告栏]\r\n#L0##n#b起源之塔探险排名#l\r\n#L2#我探险到的最深层#l", 0, 2540019)
    } else {
        if (selectionLog[1] == 0) {
            cm.openUI(211)
        } else {
            var c = getMyInfo();
            if (c == null || c.length == 0) {
                var e = 0
            } else {
                var e = c[0][0]
            }
            cm.sendNormalTalk("#e[我的累计最佳记录]#n\r\n\r\n累计最佳记录：#e#b" + e + " #k#n层", 0, 2540019, false, false)
        }
        cm.dispose()
    }
}

function getMyInfo() {
    var a = cm.queryForOneResult("SELECT `maxlevel`,`time`,`slots` FROM `oz_tower` WHERE `characterid`=?", cm.getPlayer().getId());
    if (a.isEmpty()) {
        return null
    } else {
        return [a.getInt("maxlevel"), a.getInt("time"), a.getInt("slots")]
    }
};